<template>
  <div class="ss">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="原密码：">
        <el-input v-model="form.password"></el-input>
      </el-form-item>

      <el-form-item label="新密码：">
        <el-input v-model="forms.passw"></el-input>
      </el-form-item>

      <el-form-item label="新密码:">
        <el-input v-model="forms.pass"></el-input>
      </el-form-item>
      <el-button type="primary" @click="sure">确认修改</el-button>
    </el-form>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions: SaleMapActions } = createNamespacedHelpers("sales");

export default {
  data() {
    return {
      form: {
        password: "",
      },
      forms: {
        passw: "",
        pass: "",
      },
    };
  },
  computed: {},
  async created() {
    // const _id = this.$route.params._id;
     const _id = "5f6aa2a0f97e0d3fb82c578a";
    const data = await this.getUpdataOneAsync(_id);
    this.form = data.data[0];
  },
  methods: {
    ...SaleMapActions(["getUpdataOneAsync", "SureupdataOneAsync"]),
    async sure() {
      if (this.forms.passw == this.forms.pass) {
        this.form.password = this.forms.passw;
        const data = await this.SureupdataOneAsync(this.form);
        if (data.status) {
          this.$message({
            message: "修改成功",
            type: "success",
          });
        } else {
          this.$message.error("修改失败");
        }
      }else{
         this.$message.error("两次密码输入错误");
      }
    },
  },
};
</script>

<style>
.ss {
  width: 400px;
  margin: 20px auto;
}
</style>